/*
 * Copyright 2020-2025 the original author or authors.
 * You cannot use this file unless authorized by the author.
 */
package org.ipig.constants;

/**
 * 数据相关常量
 *
 * @author <a href="mailto:comchnts@163.com">chinats</a>
 * @version $$Id: DataCnst.java 3 2020-01-21 09:36:33Z ts <comchnts@163.com> $$
 * @since 1.0
 */
public class DataCnst {
    //标识已删除
    public static final String FLAG_DELETED = "1";
    //标识正常
    public static final String FLAG_NORMAL = "0";

    /**
     * 临时表后缀
     */
    public static final String SUFFIX_TMP = "_tmp";
    /**
     * 计算临时表后缀
     */
    public static final String SUFFIX_MAPREDUCE = "_mr";
    /***  临时数据源后缀  ***/
    public static final String SUFFIX_SRC = "_src";
    /**
     * NULL_VALUE
     */
    public static final String NULL_VALUE = "NaN";
    /**
     * increment 增量
     */
    public static final String INCR = "INCREMENT";
    /**
     * FULL 全量
     */
    public static final String FULL = "FULL";

    /**
     * 数据匹配模式
     */
    public enum MatchPattern {
        /**
         * 完全匹配
         */
        FULL("FULL", "完全匹配"),
        /**
         * 左匹配
         */
        LEFT("LEFT", "左匹配"),
        /**
         * 右匹配
         */
        RIGHT("RIGHT", "右匹配"),
        /**
         * 模糊匹配
         */
        FUZZY("FUZZY", "模糊匹配");
        //code
        public final String code;
        //title
        public final String title;

        /**
         * @param code  String
         * @param title String
         */
        MatchPattern(String code, String title) {
            this.code = code;
            this.title = title;
        }

        /**
         * 解析编码
         *
         * @param code 编码
         * @return MatchPattern
         */
        public static MatchPattern parse(String code) {
            for (MatchPattern match : MatchPattern.values()) {
                if (match.code.equals(code)) {
                    return match;
                }
            }
            //默认采用全匹配方式
            return MatchPattern.FULL;
        }
    }

    /**
     * 数据输出模式
     */
    public enum OutputPattern {
        /**
         * KV单记录模式
         */
        KV_SINGLE("KV_SINGLE", "KV单记录"),
        /**
         * KV全记录模式
         */
        KV_FULL("KV_FULL", "KV全记录");
        //code
        public final String code;
        //title
        public final String title;

        /**
         * @param code  String
         * @param title String
         */
        OutputPattern(String code, String title) {
            this.code = code;
            this.title = title;
        }

        /**
         * 解析编码
         *
         * @param code 编码
         * @return OutputPattern
         */
        public static OutputPattern parse(String code) {
            for (OutputPattern type : OutputPattern.values()) {
                if (type.code.equals(code)) {
                    return type;
                }
            }
            return null;
        }
    }
}

